/**
 * Jaxson ajax
 *
 * Copyright Remedy Interactive, licensed under Apache version 2 license:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0.html
 *
 * This notice must remain in all java source files.
 */

package org.jaxson.struts;

import java.io.Serializable;
import java.util.ArrayList;


/**
 * Class which returns notification of success or failure for transactional
 * ajax requests (requests which don't return models).
 * 
 * @author Joe Maisel
 */
public class ActionExecutionResult implements Serializable
{
	private boolean succeeded;
	private String message;
	private ArrayList<String> errors = new ArrayList<String>();
	private Object payload;

	public ActionExecutionResult ()
	{
	}

	public ActionExecutionResult (boolean succeeded)
	{
		setSucceeded( succeeded );
	}

	public ActionExecutionResult (boolean succeeded, String message)
	{
		setSucceeded( succeeded );
		setMessage( message );
	}

	/**
	 * @return the succeeded
	 */
	public boolean getSucceeded()
	{
		return succeeded;
	}

	/**
	 * @param succeeded
	 *            the succeeded to set
	 */
	public void setSucceeded( boolean succeeded )
	{
		this.succeeded = succeeded;
	}

	/**
	 * @return the message
	 */
	public String getMessage()
	{
		return message;
	}

	/**
	 * @param message
	 *            the message to set
	 */
	public void setMessage( String message )
	{
		this.message = message;
	}

	public ArrayList<String> getErrors()
	{
		return errors;
	}

	public void setErrors( ArrayList<String> errors )
	{
		this.errors = errors;
	}
	
	public void addError( String error )
	{
		this.errors.add(error);
	}
	
	public Object getPayload()
	{
		return payload;
	}

	public void setPayload( Object payload )
	{
		this.payload = payload;
	}

	private static final long serialVersionUID = 983734651L;
}
